package lanou.autohome.recommend.fragments;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import lanou.autohome.URLValues;
import lanou.autohome.basetool.BaseFragment;
import lanou.autohome.R;
import lanou.autohome.basetool.NetTool;
import lanou.autohome.recommend.adapters.VideoAdapter;
import lanou.autohome.recommend.beans.VideoBean;

/**
 * Created by dllo on 16/8/15.
 * 推荐 -> 视频
 */
public class VideoFragment extends BaseFragment {

    private RecyclerView recyclerView;
    private VideoAdapter videoAdapter;

    @Override
    protected int setLayout() {
        return R.layout.fragment_recommend_video;
    }

    @Override
    protected void initView() {

        recyclerView = bindVie(R.id.recyclerView_video_recommend);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    }

    @Override
    protected void intiData() {

        videoAdapter = new VideoAdapter(getContext());
        mNetTool.getNetData(URLValues.VIDEO_URL, VideoBean.class, new NetTool.NetListener<VideoBean>() {
            @Override
            public void onSuccess(VideoBean videoBean) {
                videoAdapter.setVideoBean(videoBean);
                recyclerView.setAdapter(videoAdapter);
            }

            @Override
            public void onError(String errorMsg) {

            }
        });
    }
}
